package com.zhuss.core.book;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.bean.bo.core.book.CreateBookBo;
import com.zhuss.bean.bo.core.book.DeleteBookBo;
import com.zhuss.bean.bo.core.book.StartBookBo;
import com.zhuss.bean.bo.core.book.StopBookBo;
import com.zhuss.bean.bo.core.book.UpdateBookBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.AabException;

/**
 * Book操作service（基本操作）
 * @author zhushanshuo
 * @Date 2019-12-13 15:59
 *
 */
@Component("bookOperateService")
public class BookOperateService implements OperateService<Void, Object> {
	
	@Autowired
	@Qualifier("bookCreate")
	private Processor<Object, CreateBookBo> bookCreate;
	
	@Autowired
	@Qualifier("bookUpdate")
	private Processor<Object, UpdateBookBo> bookUpdate;
	
	
	@Autowired
	@Qualifier("bookDelete")
	private Processor<Object, DeleteBookBo> bookDelete;
	
	
	@Autowired
	@Qualifier("bookStart")
	private Processor<Object, StartBookBo> bookStart;
	
	@Autowired
	@Qualifier("bookStop")
	private Processor<Object, StopBookBo> bookStop;
	
	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws AabException {
		
		CreateBookBo bo = (CreateBookBo) param;
		
		bookCreate.process(bo);
		
		return null;
	}
    
	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws AabException {
    	
		UpdateBookBo bo = (UpdateBookBo) param;
		
		bookUpdate.process(bo);
		
    	return null;
    }
	
	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws AabException {
		
		DeleteBookBo bo = (DeleteBookBo) param;
		
		bookDelete.process(bo);
		
		return null;
	}
	
	
	/**
	 * 启用
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void start(Object param) throws AabException {
		
		StartBookBo bo = (StartBookBo) param;
		
		bookStart.process(bo);
		
		return null;
	}
	
	/**
	 * 停用
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void stop(Object param) throws AabException {
		
		StopBookBo bo = (StopBookBo) param;
		
		bookStop.process(bo);
		
		return null;
	}
	
	
	
	
	
}

